package com.sgb.kjwl.view.ui.activity.self.userInfo;

import android.content.Context;
import android.content.Intent;
import androidx.databinding.DataBindingUtil;
import android.view.View;

import com.sgb.kjwl.AppActivity;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ActivityRegistrationWelcomeBinding;
import com.sgb.kjwl.di.self.DaggerSelfComponent;
import com.sgb.kjwl.di.self.SelfModule;
import com.swgk.core.event.EventConstant;
import com.sgb.kjwl.view.event.LoginEvent;
import com.sgb.kjwl.view.event.LogisticsEvent;
import com.sgb.kjwl.view.ui.activity.MainActivity;
import com.sgb.kjwl.view.ui.activity.self.JoinCompanyActivity;
import com.sgb.kjwl.view.ui.activity.self.authentication.CertificationActivity;
import com.sgb.kjwl.view.ui.activity.vehicleManagement.AddDriverInfoActivity;
import com.sgb.kjwl.viewmodel.self.RegWelModel;
import com.swgk.core.base.di.AppComponent;

import org.greenrobot.eventbus.EventBus;

import javax.inject.Inject;

public class RegistrationWelcomeActivity extends AppActivity {

    ActivityRegistrationWelcomeBinding binding;

    @Inject
    RegWelModel model;
    String isDriver;
    private int state;
    private String realname;
    public static void start(Context context) {
        Intent intent = new Intent(context, RegistrationWelcomeActivity.class);
        context.startActivity(intent);
    }
    public static void start(Context context,String realname) {
        Intent intent = new Intent(context, RegistrationWelcomeActivity.class);
        intent.putExtra("realname",realname);
        context.startActivity(intent);
    }

    @Override
    protected void setupActivityComponent(AppComponent appComponent) {
        DaggerSelfComponent.builder()
                .appComponent(appComponent)
                .selfModule(new SelfModule(this))
                .build()
                .inject(this);
    }

    @Override
    protected void initView() {
        binding = DataBindingUtil.setContentView(RegistrationWelcomeActivity.this, R.layout.activity_registration_welcome);
        realname =getIntent().getStringExtra("realname");
        binding.tvGoBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                /*Intent intent = new Intent();
                intent.putExtra("showPage", "FRAGMENT_HOME");*/
                EventBus.getDefault().postSticky(LoginEvent.make(EventConstant.EVENT_MAIN_INDEX, 0));  //主动通知刷新消息通讯录数据
                EventBus.getDefault().postSticky(LogisticsEvent.make(EventConstant.EVENT_USER_CENTER_JUMP, 0));  //主动通知刷新用户中心数据
                MainActivity.start(getActivity());
            }
        });
        binding.certification.setOnClickListener(this);
        binding.joinEnterprise.setOnClickListener(this);
        binding.enterpriseCertification.setOnClickListener(this);
        binding.driverCertification.setOnClickListener(this);
        binding.icBack.setOnClickListener(this);
    }

    @Override
    protected void init() {
        super.init();
    }

    @Override
    public void onMultiClick(View v) {
        switch (v.getId()) {
            case R.id.certification://实名认证
                CertificationActivity.start(this);
                break;
            case R.id.join_enterprise://加入企业
                JoinCompanyActivity.start(this);
                break;
            case R.id.enterprise_certification://企业认证
                RegisterActivity3.start(this, true);
                break;
            case R.id.driver_certification://司机认证
                Intent intent = new Intent(getActivity(), AddDriverInfoActivity.class);
                intent.putExtra("name",realname);
                intent.putExtra("cardId", "");
                startActivity(intent);
//                Intent intent = new Intent();
//                intent.setClass(this, AddVehicleActivity.class);
//                startActivityForResult(intent, state);
                break;
            case R.id.ic_back:
                EventBus.getDefault().postSticky(LoginEvent.make(EventConstant.EVENT_MAIN_INDEX, 0));  //主动通知刷新消息通讯录数据
                EventBus.getDefault().postSticky(LogisticsEvent.make(EventConstant.EVENT_USER_CENTER_JUMP, 0));  //主动通知刷新用户中心数据
                MainActivity.start(getActivity());
                break;
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 0 && resultCode == 1){
            state = data.getIntExtra("state", 0);
        }
    }

}